{% extends 'layout.html' %}
{% load static %}
{% block content %}
    {% load permission %}
    <div style="margin-bottom: 5px;" class="clearfix">
        {% add_permission request 'policy_add' %}
    </div>

    <table class="table table-bordered">
        <thead>
        <tr>
            <th>ID</th>
            <th>数量</th>
            <th>价格 (元)</th>
            {% if request|check_permission:"policy_edit,policy_delete" %}
                <th>操作</th>
            {% endif %}

        </tr>
        </thead>
        <tbody>
        {% for row in paginator.queryset %}
            <tr row-id={{ row.id }}>
                <td>{{ row.id }}</td>
                <td>{{ row.count }}</td>
                <td>{{ row.price }} </td>
                {% if request|check_permission:"policy_edit,policy_delete" %}
                    <td>
                        {% edit_permission request 'policy_edit' row.id %}
                        {% delete_permission request 'policy_delete' pk=row.id %}
                    </td>
                {% endif %}

            </tr>
        {% endfor %}
        </tbody>
    </table>
    <ul class="pagination">
        {{ paginator.html }}
    </ul>

    {% include 'include/delete_modal.html' %}
{% endblock %}
{% block js %}
    <script src="{% static 'js/delete_modal.js' %}"></script>
    <script>
        let DELETE_ID
        let DELETE_URL = "{%  url 'policy_delete' %}"
    </script>
{% endblock %}